//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.tzbank.poc.util;

import ch.qos.logback.core.Appender;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;

import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Map.Entry;
import java.util.regex.Pattern;

import com.tzbank.poc.util.Debug;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;

public class StringUtil {
    public static final StringUtil INSTANCE = new StringUtil();
    public static final String module = StringUtil.class.getName();
    private static final Map<String, Pattern> substitutionPatternMap = new HashMap<String, Pattern>() {
        {
            put("&&", Pattern.compile("@and", 16));
            substitutionPatternMap.put("||", Pattern.compile("@or", 16));
            substitutionPatternMap.put("<=", Pattern.compile("@lteq", 16));
            substitutionPatternMap.put(">=", Pattern.compile("@gteq", 16));
            substitutionPatternMap.put("<", Pattern.compile("@lt", 16));
            substitutionPatternMap.put(">", Pattern.compile("@gt", 16));
        }
    };
    private static char[] hexChar = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    public static final char UNDERLINE = '_';

//    private static Map<String, Pattern> createSubstitutionPatternMap() {
//        Map<String, Pattern> substitutionPatternMap = new LinkedHashMap();
//        substitutionPatternMap.put("&&", Pattern.compile("@and", 16));
//        substitutionPatternMap.put("||", Pattern.compile("@or", 16));
//        substitutionPatternMap.put("<=", Pattern.compile("@lteq", 16));
//        substitutionPatternMap.put(">=", Pattern.compile("@gteq", 16));
//        substitutionPatternMap.put("<", Pattern.compile("@lt", 16));
//        substitutionPatternMap.put(">", Pattern.compile("@gt", 16));
//        return Collections.unmodifiableMap(substitutionPatternMap);
//    }

    private StringUtil() {
    }

    public static String internString(String value) {
        return value != null ? value.intern() : null;
    }

    public static String replaceString(String mainString, String oldString, String newString) {
        if (mainString == null) {
            return null;
        } else if (ValidateUtil.isEmpty(oldString)) {
            return mainString;
        } else {
            if (newString == null) {
                newString = "";
            }

            int i = mainString.lastIndexOf(oldString);
            if (i < 0) {
                return mainString;
            } else {
                StringBuilder mainSb;
                for (mainSb = new StringBuilder(mainString); i >= 0; i = mainString.lastIndexOf(oldString, i - 1)) {
                    mainSb.replace(i, i + oldString.length(), newString);
                }

                return mainSb.toString();
            }
        }
    }

    public static String join(List<?> list, String delim) {
        return join((Collection) list, delim);
    }

    public static String join(Collection<?> col, String delim) {
        if (ValidateUtil.isEmpty(col)) {
            return null;
        } else {
            StringBuilder buf = new StringBuilder();
            Iterator i = col.iterator();

            while (i.hasNext()) {
                buf.append(i.next());
                if (i.hasNext()) {
                    buf.append(delim);
                }
            }

            return buf.toString();
        }
    }

    public static List<String> split(String str, String delim) {
        List<String> splitList = null;
        if (str == null) {
            return null;
        } else {
            StringTokenizer st = delim != null ? new StringTokenizer(str, delim) : new StringTokenizer(str);
            if (st.hasMoreTokens()) {
                splitList = new LinkedList();

                while (st.hasMoreTokens()) {
                    splitList.add(st.nextToken());
                }
            }

            return splitList;
        }
    }

    public static List<String> split(String str, String delim, int limit) {
        List<String> splitList = null;
        String[] st = null;
        if (str == null) {
            return splitList;
        } else {
            if (delim != null) {
                st = Pattern.compile(delim).split(str, limit);
            } else {
                st = str.split("\\s");
            }

            if (st != null && st.length > 0) {
                splitList = new LinkedList();

                for (int i = 0; i < st.length; ++i) {
                    splitList.add(st[i]);
                }
            }

            return splitList;
        }
    }

    public static List<String> quoteStrList(List<String> list) {
        List<String> tmpList = list;
        list = new LinkedList();
        Iterator var2 = tmpList.iterator();

        while (var2.hasNext()) {
            String str = (String) var2.next();
            str = "'" + str + "'";
            list.add(str);
        }

        return list;
    }

    public static Map<String, String> strToMap(String str, String delim, boolean trim) {
        return strToMap(str, delim, trim, null);
    }

    public static Map<String, String> strToMap(String str, String delim, boolean trim, String pairsSeparator) {
        if (str == null) {
            return null;
        } else {
            Map<String, String> decodedMap = new HashMap();
            List<String> elements = split(str, delim);
            pairsSeparator = pairsSeparator == null ? "=" : pairsSeparator;
            Iterator var6 = elements.iterator();

            while (var6.hasNext()) {
                String s = (String) var6.next();
                List<String> e = split(s, pairsSeparator);
                if (e.size() == 2) {
                    String name = e.get(0);
                    String value = e.get(1);
                    if (trim) {
                        if (name != null) {
                            name = name.trim();
                        }

                        if (value != null) {
                            value = value.trim();
                        }
                    }

                    if (!StringUtils.isEmpty(name)) {
                        if (StringUtils.isEmpty(value)) {
                            value = "";
                        }

                        try {
                            decodedMap.put(URLDecoder.decode(name, "UTF-8"), URLDecoder.decode(value, "UTF-8"));
                        } catch (UnsupportedEncodingException var12) {
                            Debug.logError(var12, module);
                        }
                    }
                }
            }

            return decodedMap;
        }
    }

    public static Map<String, String> strToMap(String str, boolean trim) {
        return strToMap(str, "|", trim);
    }

    public static Map<String, String> strToMap(String str, String delim) {
        return strToMap(str, delim, false);
    }

    public static Map<String, String> strToMap(String str) {
        return strToMap(str, "|", false);
    }

    public static String mapToStr(Map<? extends Object, ? extends Object> map) {
        if (map == null) {
            return null;
        } else {
            StringBuilder buf = new StringBuilder();
            boolean first = true;
            Iterator var3 = map.entrySet().iterator();

            while (var3.hasNext()) {
                Entry<? extends Object, ? extends Object> entry = (Entry) var3.next();
                Object key = entry.getKey();
                Object value = entry.getValue();
                if (key instanceof String && value instanceof String) {
                    String encodedName = null;

                    try {
                        encodedName = URLEncoder.encode((String) key, "UTF-8");
                    } catch (UnsupportedEncodingException var11) {
                        Debug.logError(var11, module);
                    }

                    String encodedValue = null;

                    try {
                        encodedValue = URLEncoder.encode((String) value, "UTF-8");
                    } catch (UnsupportedEncodingException var10) {
                        Debug.logError(var10, module);
                    }

                    if (first) {
                        first = false;
                    } else {
                        buf.append("|");
                    }

                    buf.append(encodedName);
                    buf.append("=");
                    buf.append(encodedValue);
                }
            }

            return buf.toString();
        }
    }

    public static Map<String, String> toMap(String s) {
        Map<String, String> newMap = new HashMap();
        if (s.startsWith("{") && s.endsWith("}")) {
            s = s.substring(1, s.length() - 1);
            String[] entries = s.split("\\,\\s");
            String[] var3 = entries;
            int var4 = entries.length;

            for (int var5 = 0; var5 < var4; ++var5) {
                String entry = var3[var5];
                String[] nv = entry.split("\\=");
                if (nv.length == 2) {
                    newMap.put(nv[0], nv[1]);
                }
            }

            return newMap;
        } else {
            throw new IllegalArgumentException("String is not from Map.toString()");
        }
    }

    public static List<String> toList(String s) {
        List<String> newList = new LinkedList();
        if (s.startsWith("[") && s.endsWith("]")) {
            s = s.substring(1, s.length() - 1);
            String[] entries = s.split("\\,\\s");
            String[] var3 = entries;
            int var4 = entries.length;

            for (int var5 = 0; var5 < var4; ++var5) {
                String entry = var3[var5];
                newList.add(entry);
            }

            return newList;
        } else {
            throw new IllegalArgumentException("String is not from List.toString()");
        }
    }

    public static Set<String> toSet(String s) {
        Set<String> newSet = new LinkedHashSet();
        if (s.startsWith("[") && s.endsWith("]")) {
            s = s.substring(1, s.length() - 1);
            String[] entries = s.split("\\,\\s");
            String[] var3 = entries;
            int var4 = entries.length;

            for (int var5 = 0; var5 < var4; ++var5) {
                String entry = var3[var5];
                newSet.add(entry);
            }

            return newSet;
        } else {
            throw new IllegalArgumentException("String is not from Set.toString()");
        }
    }

    public static <K, V> Map<K, V> createMap(List<K> keys, List<V> values) {
        if (keys != null && values != null && keys.size() == values.size()) {
            Map<K, V> newMap = new HashMap();

            for (int i = 0; i < keys.size(); ++i) {
                newMap.put(keys.get(i), values.get(i));
            }

            return newMap;
        } else {
            throw new IllegalArgumentException("Keys and Values cannot be null and must be the same size");
        }
    }

    public static String cleanUpPathPrefix(String prefix) {
        if (ValidateUtil.isEmpty(prefix)) {
            return "";
        } else {
            StringBuilder cppBuff = new StringBuilder(prefix.replace('\\', '/'));
            if (cppBuff.charAt(0) != '/') {
                cppBuff.insert(0, '/');
            }

            if (cppBuff.charAt(cppBuff.length() - 1) == '/') {
                cppBuff.deleteCharAt(cppBuff.length() - 1);
            }

            return cppBuff.toString();
        }
    }

    public static String removeSpaces(String str) {
        return removeRegex(str, "[\\ ]");
    }

    public static String toHexString(byte[] bytes) {
        return new String(Hex.encodeHex(bytes));
    }

    public static String cleanHexString(String str) {
        StringBuilder buf = new StringBuilder();

        for (int i = 0; i < str.length(); ++i) {
            if (str.charAt(i) != ' ' && str.charAt(i) != ':') {
                buf.append(str.charAt(i));
            }
        }

        return buf.toString();
    }

    public static byte[] fromHexString(String str) {
        str = cleanHexString(str);

        try {
            return Hex.decodeHex(str.toCharArray());
        } catch (Exception var2) {
            throw new RuntimeException(var2);
        }
    }

    public static int convertChar(char c) {
        if ('0' <= c && c <= '9') {
            return c - 48;
        } else if ('a' <= c && c <= 'f') {
            return c - 97 + 10;
        } else if ('A' <= c && c <= 'F') {
            return c - 65 + 10;
        } else {
            throw new IllegalArgumentException("Invalid hex character: [" + c + "]");
        }
    }

    public static char[] encodeInt(int i, int j, char[] digestChars) {
        if (i < 16) {
            digestChars[j] = '0';
        }

        ++j;

        do {
            digestChars[j--] = hexChar[i & 15];
            i >>>= 4;
        } while (i != 0);

        return digestChars;
    }

    public static String removeNonNumeric(String str) {
        return removeRegex(str, "[\\D]");
    }

    public static String removeNumeric(String str) {
        return removeRegex(str, "[\\d]");
    }

    public static String removeRegex(String str, String regex) {
        return str.replaceAll(regex, "");
    }

    public static String addToNumberString(String numberString, long addAmount) {
        if (numberString == null) {
            return null;
        } else {
            int origLength = numberString.length();
            long number = Long.parseLong(numberString);
            return padNumberString(Long.toString(number + addAmount), origLength);
        }
    }

    public static String padNumberString(String numberString, int targetMinLength) {
        StringBuilder outStrBfr = new StringBuilder(numberString);

        while (targetMinLength > outStrBfr.length()) {
            outStrBfr.insert(0, '0');
        }

        return outStrBfr.toString();
    }

    public static String padNumberStringRight(String numberString, int targetMinLength) {
        StringBuilder outStrBfr = new StringBuilder(numberString);

        while (targetMinLength > outStrBfr.length()) {
            outStrBfr.insert(outStrBfr.length(), '0');
        }

        return outStrBfr.toString();
    }

    public static String convertOperatorSubstitutions(String expression) {
        String result = expression;
        if (expression != null && expression.contains("@")) {
            Entry entry;
            Pattern pattern;
            for (Iterator var2 = substitutionPatternMap.entrySet().iterator(); var2.hasNext(); result = pattern.matcher(result).replaceAll((String) entry.getKey())) {
                entry = (Entry) var2.next();
                pattern = (Pattern) entry.getValue();
            }

            if (Debug.verboseOn()) {
                Debug.logVerbose("Converted " + expression + " to " + result, module);
            }
        }

        return result;
    }

    public static String collapseNewlines(String str) {
        return collapseCharacter(str, '\n');
    }

    public static String collapseSpaces(String str) {
        return collapseCharacter(str, ' ');
    }

    public static String collapseCharacter(String str, char c) {
        StringBuilder sb = new StringBuilder();
        char last = str.charAt(0);

        for (int i = 0; i < str.length(); ++i) {
            char current = str.charAt(i);
            if (i == 0 || current != c || last != c) {
                sb.append(current);
                last = current;
            }
        }

        return sb.toString();
    }

    public static StringUtil.StringWrapper wrapString(String theString) {
        return makeStringWrapper(theString);
    }

    public static StringUtil.StringWrapper makeStringWrapper(String theString) {
        if (theString == null) {
            return null;
        } else {
            return theString.length() == 0 ? StringUtil.StringWrapper.EMPTY_STRING_WRAPPER : new StringUtil.StringWrapper(theString);
        }
    }

//    public static StringBuilder appendTo() {
//        return appendTo(sb, iterable, prefix, suffix, (String)null, sep, (String)null);
//    }

    public static StringBuilder appendTo(StringBuilder sb, Iterable<? extends Appender<StringBuilder>> iterable, String prefix, String suffix, String sepPrefix, String sep, String sepSuffix) {
        Iterator it = iterable.iterator();

        while (it.hasNext()) {
            if (prefix != null) {
                sb.append(prefix);
            }

//            StringBuilder stringBuilder = appendTo();
            if (suffix != null) {
                sb.append(suffix);
            }

            if (it.hasNext() && sep != null) {
                if (sepPrefix != null) {
                    sb.append(sepPrefix);
                }

                sb.append(sep);
                if (sepSuffix != null) {
                    sb.append(sepSuffix);
                }
            }
        }

        return sb;
    }

    public static StringBuilder append(StringBuilder sb, Iterable<? extends Object> iterable, String prefix, String suffix, String sep) {
        return append(sb, iterable, prefix, suffix, null, sep, null);
    }

    public static StringBuilder append(StringBuilder sb, Iterable<? extends Object> iterable, String prefix, String suffix, String sepPrefix, String sep, String sepSuffix) {
        Iterator it = iterable.iterator();

        while (it.hasNext()) {
            if (prefix != null) {
                sb.append(prefix);
            }

            sb.append(it.next());
            if (suffix != null) {
                sb.append(suffix);
            }

            if (it.hasNext() && sep != null) {
                if (sepPrefix != null) {
                    sb.append(sepPrefix);
                }

                sb.append(sep);
                if (sepSuffix != null) {
                    sb.append(sepSuffix);
                }
            }
        }

        return sb;
    }

    public static String mapToJsonString(Map<String, Object> inputMap) {
        if (null == inputMap) {
            return null;
        } else {
            String jsonString = JSON.toJSONString(inputMap, SerializerFeature.WriteBigDecimalAsPlain);
            return jsonString;
        }
    }

    public static Map<String, Object> jsonStringToMap(String jsonString, int... length) {
        SerializeConfig config = SerializeConfig.getGlobalInstance();
        config.put(BigDecimal.class, BigDecimalCodecDefined.instance);
        if (StringUtils.isEmpty(jsonString)) {
            return null;
        } else {
            new HashMap();
            JSONObject jsonObject = JSONObject.parseObject(jsonString);
            Map<String, Object> inputMap = JSONObject.parseObject(jsonObject.toJSONString(), new TypeReference<Map<String, Object>>() {
            });
            return inputMap;
        }
    }

    public static List jsonStringToList(String jsonString) {
        if (StringUtils.isEmpty(jsonString)) {
            return null;
        } else {
            List inputList = new ArrayList();
            Object jsonObject = JSONObject.parse(jsonString);
            if (!(jsonObject instanceof JSONArray)) {
                return null;
            } else {
                JSONArray ja = (JSONArray) jsonObject;
                JSONObject jo = null;

                for (int i = 0; i < ja.size(); ++i) {
                    jo = ja.getJSONObject(i);
                    Map<String, Object> inputListMap = JSONObject.parseObject(jo.toJSONString(), new TypeReference<Map<String, Object>>() {
                    });
                    inputList.add(inputListMap);
                }

                return inputList;
            }
        }
    }

    public static boolean isEmptyStr(String str) {
        return str == null || str.trim().length() == 0;
    }

    public static boolean isStrInArray(String keyString, String[] arrayStr) {
        if (keyString == null) {
            return false;
        } else if (arrayStr == null) {
            return false;
        } else {
            String[] var2 = arrayStr;
            int var3 = arrayStr.length;

            for (int var4 = 0; var4 < var3; ++var4) {
                String element = var2[var4];
                if (keyString.equals(element)) {
                    return true;
                }
            }

            return false;
        }
    }

    public static boolean hasDuplicateElementInStringArr(String[] strs) {
        return hasDuplicateElementInStringArr(null, strs, true);
    }

    public static boolean hasDuplicateElementInStringArr(Set<String> all, String[] strs, boolean addInAll) {
        if (strs != null && strs.length != 0) {
            if (all == null) {
                all = new HashSet();
            }

            if (!addInAll) {
                Set<String> temp = new HashSet();
                temp.addAll(all);
                all = temp;
            }

            String[] var7 = strs;
            int var4 = strs.length;

            for (int var5 = 0; var5 < var4; ++var5) {
                String str = var7[var5];
                if (all.contains(str)) {
                    return true;
                }

                all.add(str);
            }

            return false;
        } else {
            return false;
        }
    }

    public static String fillStrWithDigit(String ori, char thefillChar, int digit, boolean isPrefix) {
        StringBuilder sb = new StringBuilder();
        sb.append(ori);
        fillStrWithDigit(sb, thefillChar, digit, isPrefix);
        return sb.toString();
    }

    public static void fillStrWithDigit(StringBuilder ori, char thefillChar, int digit, boolean isPrefix) {
        if (ori == null) {
            ori = new StringBuilder();
        }

        int i;
        if (isPrefix) {
            for (i = 0; i < digit; ++i) {
                ori.insert(0, thefillChar);
            }
        } else {
            for (i = 0; i < digit; ++i) {
                ori.append(thefillChar);
            }
        }

    }

    public static String fillStrToDigit(String ori, char thefillChar, int digit, boolean isPrefix) {
        if (ori.length() >= digit) {
            return ori;
        } else {
            StringBuilder sb = new StringBuilder();
            sb.append(ori);
            fillStrToDigit(sb, thefillChar, digit, isPrefix);
            return sb.toString();
        }
    }

    public static void fillStrToDigit(StringBuilder ori, char thefillChar, int digit, boolean isPrefix) {
        if (ori == null) {
            ori = new StringBuilder();
        }

        if (ori.length() < digit) {
            int i;
            if (isPrefix) {
                for (i = ori.length(); i < digit; ++i) {
                    ori.insert(0, thefillChar);
                }
            } else {
                for (i = ori.length(); i < digit; ++i) {
                    ori.append(thefillChar);
                }
            }

        }
    }

    public static String formatBytes(byte[] theBytes, String encoding, int byteGroupNum, int byteNumInGroup, String byteGap, String byteGroupGap, String byteTxtgap, int txtChaNum, String replaceCharRules) {
        int iByteIndex = 0;
        int iCharIndex = 0;
        String theChars = null;

        try {
            theChars = new String(theBytes, encoding);
        } catch (UnsupportedEncodingException var17) {
            var17.printStackTrace();
        }

        if (!isEmptyStr(replaceCharRules)) {
            String[] var12 = replaceCharRules.split(";");
            int var13 = var12.length;

            for (int var14 = 0; var14 < var13; ++var14) {
                String aRule = var12[var14];
                String[] aRuleArr = aRule.split(":");
                theChars = theChars.replaceAll(aRuleArr[0], aRuleArr[1]);
            }
        }

        StringBuilder sb = new StringBuilder();

        while (iByteIndex < theBytes.length - 1 || iCharIndex < theChars.length() - 1) {
            iByteIndex = writeAlineBytePart(theBytes, byteGroupNum, byteNumInGroup, byteGap, byteGroupGap, sb, iByteIndex);
            sb.append(byteTxtgap);
            iCharIndex = writeAlineCharPart(theChars, txtChaNum, sb, iCharIndex);
            sb.append(System.lineSeparator());
        }

        return sb.toString();
    }

    private static int writeAlineBytePart(byte[] theBytes, int byteGroupNum, int byteNumInGroup, String byteGap, String byteGroupGap, StringBuilder sb, int curByteIdx) {
        for (int i = 0; i < byteGroupNum; ++i) {
            curByteIdx = writeAlineByteGroupPart(theBytes, byteNumInGroup, byteGap, sb, curByteIdx);
            if (i < byteGroupNum - 1) {
                sb.append(byteGroupGap);
            }
        }

        return curByteIdx;
    }

    private static void writeEmptyBytePartInGroup(int groupAlreadyWrite, int byteNumInGroup, String byteGap, StringBuilder sb) {
        if (groupAlreadyWrite < byteNumInGroup) {
            if (groupAlreadyWrite > 0) {
                sb.append(byteGap);
            }

            for (int i = groupAlreadyWrite; i < byteNumInGroup; ++i) {
                sb.append("  ");
                if (i < byteNumInGroup - 1) {
                    sb.append(byteGap);
                }
            }

        }
    }

    private static int writeAlineByteGroupPart(byte[] theBytes, int byteNumInGroup, String byteGap, StringBuilder sb, int curByteIdx) {
        int groupAlreadyWrite = 0;
        if (curByteIdx >= theBytes.length - 1) {
            writeEmptyBytePartInGroup(groupAlreadyWrite, byteNumInGroup, byteGap, sb);
            return curByteIdx;
        } else {
            int nextIdx = curByteIdx + byteNumInGroup;
            if (nextIdx > theBytes.length) {
                nextIdx = theBytes.length;
            }

            for (int i = curByteIdx; i < nextIdx; ++i) {
                sb.append(fillStrToDigit(Integer.toHexString(theBytes[i] & 255).toUpperCase(), '0', 2, true));
                ++groupAlreadyWrite;
                if (i < nextIdx - 1) {
                    sb.append(byteGap);
                }
            }

            writeEmptyBytePartInGroup(groupAlreadyWrite, byteNumInGroup, byteGap, sb);
            return nextIdx;
        }
    }

    private static int writeAlineCharPart(String theChars, int txtChaNum, StringBuilder sb, int iCharIndex) {
        if (iCharIndex >= theChars.length() - 1) {
            return iCharIndex;
        } else {
            int nextIdx = iCharIndex + txtChaNum;
            if (nextIdx > theChars.length()) {
                sb.append(theChars.substring(iCharIndex, theChars.length()));
                return theChars.length() - 1;
            } else {
                sb.append(theChars.substring(iCharIndex, nextIdx));
                return nextIdx;
            }
        }
    }

    public static int getTotalLevels(String oriStr, String spliter) {
        int totalLevel = 1;

        for (int nextIdx = oriStr.indexOf(spliter); nextIdx >= 0; nextIdx = oriStr.indexOf(spliter, nextIdx + spliter.length())) {
            ++totalLevel;
        }

        return totalLevel;
    }

    public static String subString(String oriStr, String spliter, int level) {
        return subString(oriStr, spliter, 0, level + 1);
    }

    public static String subString(String oriStr, String spliter, int idxStart, int idxEnd) {
        if (oriStr != null && spliter != null && !spliter.equals("")) {
            if (idxStart < 0) {
                throw new IllegalArgumentException("start index can't be less than 0");
            } else if (idxStart >= idxEnd) {
                throw new IllegalArgumentException("start index can't be larger than end index");
            } else {
                int start = -1;
                int end = -1;
                if (idxStart == 0) {
                    start = 0;
                }

                int lastValidIndex = 0;
                int spliterLen = spliter.length();

                for (int i = 0; i < idxEnd; ++i) {
                    int curValidIndex;
                    if (lastValidIndex == 0) {
                        curValidIndex = oriStr.indexOf(spliter, lastValidIndex);
                    } else {
                        curValidIndex = oriStr.indexOf(spliter, lastValidIndex + spliterLen);
                    }

                    if (curValidIndex < 0) {
                        if (lastValidIndex == oriStr.length()) {
                            return "";
                        }

                        curValidIndex = oriStr.length();
                    }

                    if (i == idxStart - 1) {
                        start = curValidIndex + spliterLen;
                    }

                    if (i == idxEnd - 1) {
                        if (curValidIndex < 0) {
                            end = oriStr.length();
                        } else {
                            end = curValidIndex;
                        }
                    }

                    lastValidIndex = curValidIndex;
                }

                if (start >= 0 && end >= 0) {
                    return oriStr.substring(start, end);
                } else {
                    return "";
                }
            }
        } else {
            return oriStr;
        }
    }

//    public static String getEsExpsValue(String strHasEsExp, Delegator delegator) {
//        if (strHasEsExp != null && strHasEsExp.indexOf("${") >= 0) {
//            StringBuilder result = new StringBuilder();
//            List<String> theEsExps = getEsExps(strHasEsExp);
//            Iterator var4 = theEsExps.iterator();
//
//            while(var4.hasNext()) {
//                String esExp = (String)var4.next();
//                if (esExp.indexOf("${") != 0) {
//                    result.append(esExp);
//                } else {
//                    result.append(getExExpValue(esExp, delegator));
//                }
//            }
//
//            return result.toString();
//        } else {
//            return strHasEsExp;
//        }
//    }
//
//    private static String getExExpValue(String exExp, Delegator delegator) {
//        String[] esValues = exExp.substring(2).split(";");
//        if (esValues[0].equals("seq")) {
//            String seqValue = delegator.getNextSeqIdLong(esValues[3], 1L).toString();
//            return fillStrToDigit(seqValue, esValues[3].charAt(0), Integer.parseInt(esValues[2]), Boolean.parseBoolean(esValues[4]));
//        } else {
//            return esValues[0].equals("current_date") ? (new SimpleDateFormat(esValues[1])).format(Calendar.getInstance().getTime()) : exExp.substring(2);
//        }
//    }

    protected static List<String> getEsExps(String strHasEsExp) {
        List<String> esExps = new ArrayList();
        int curIdx = 0;
        boolean var3 = false;

        do {
            int nextIdx;
            if ((nextIdx = strHasEsExp.indexOf("${", curIdx)) < 0) {
                esExps.add(strHasEsExp.substring(curIdx));
                return esExps;
            }

            if (curIdx < nextIdx) {
                esExps.add(strHasEsExp.substring(curIdx, nextIdx));
                curIdx = strHasEsExp.indexOf("}", nextIdx);
                ++curIdx;
            }

            curIdx = strHasEsExp.indexOf("}", nextIdx);
            esExps.add(strHasEsExp.substring(nextIdx, curIdx));
            ++curIdx;
        } while (curIdx < strHasEsExp.length());

        return esExps;
    }

    public static String getCamelFromDbCol(String columnName) {
        if (columnName == null) {
            return null;
        } else {
            StringBuilder sb = new StringBuilder();
            boolean foundUndline = false;

            for (int i = 0; i < columnName.length(); ++i) {
                char c = columnName.charAt(i);
                if (c == '_') {
                    foundUndline = true;
                } else if (foundUndline) {
                    sb.append(Character.toUpperCase(c));
                    foundUndline = false;
                } else {
                    sb.append(Character.toLowerCase(c));
                }
            }

            return sb.toString();
        }
    }

    public static String camelToUnderline(String param) {
        if (param != null && !"".equals(param.trim())) {
            int len = param.length();
            StringBuilder sb = new StringBuilder(len);

            for (int i = 0; i < len; ++i) {
                char c = param.charAt(i);
                if (Character.isUpperCase(c)) {
                    if (i != 0) {
                        sb.append('_');
                    }

                    sb.append(Character.toLowerCase(c));
                } else {
                    sb.append(c);
                }
            }

            return sb.toString();
        } else {
            return "";
        }
    }

    public static Date formatDateStr(String dateStr) {
        try {
            if (dateStr.matches("[0-9]{3}[1-9]-[0-1]{0,1}[1-9]-[0-3][0-9]")) {
                return (new SimpleDateFormat("yyyy-MM-dd")).parse(dateStr);
            }

            if (dateStr.matches("[0-9]{3}[1-9]/[0-1]{0,1}[1-9]/[0-3][0-9]")) {
                return (new SimpleDateFormat("yyyy/MM/dd")).parse(dateStr);
            }

            if (dateStr.matches("[0-9]{3}[1-9]/[0-1]{0,1}[1-9]/[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]")) {
                return (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).parse(dateStr);
            }

            if (dateStr.matches("[0-9]{3}[1-9]-[0-1]{0,1}[1-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]")) {
                return (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).parse(dateStr);
            }
        } catch (Exception var2) {
            var2.printStackTrace();
        }

        return null;
    }

    public static class StringWrapper {
        public static final StringUtil.StringWrapper EMPTY_STRING_WRAPPER = new StringUtil.StringWrapper("");
        protected String theString;

        protected StringWrapper() {
        }

        public StringWrapper(String theString) {
            this.theString = theString;
        }

        public String plus(Object value) {
            return this.theString + value;
        }

        @Override
        public String toString() {
            return this.theString;
        }
    }
}
